#ifndef PHYSX_LOGIC_H
#define PHYSX_LOGIC_H

#define NOMINMAX
#include <windows.h>

#include <PhysXLoader.h>
#include <NxPhysicsSDK.h>
#include <NxScene.h>
#include <NxVec3.h>
#include <NxMath.h>
#include <NxMaterial.h>

#include <NxActor.h>

#include <NxShape.h>
#include <NxBoxShape.h>
#include <NxSphereShape.h>

#include "..\_Utils\src\DebugRenderer.h"
#include "..\_Utils\src\Camera.h"
#include "..\_Utils\src\Scene.h"

#include "Renderer.h"

class PhysxLogic
{
private:
    static NxPhysicsSDK *physicsSDK;
    static const NxDebugRenderable *debugRenderable;
    static bool debugRenderingIsEnabled;

    static Scene *sampleScene;

public:
    static NxScene *physicsScene;
    static Camera *cam;
    static DebugRenderer *debugRenderer;

public:
    static bool Init(Scene *scene);
    static void PrepareScene();
    static void SimulateAndRender();
    static void Exit();

    static inline bool IsDebugRenderingEnabled() { return debugRenderingIsEnabled; }
    static inline void SetDebugRenderingEnabled(bool isEnabled) { debugRenderingIsEnabled = isEnabled; }

    static void HandleKeyboardEvent(unsigned char key, int x, int y);
    static void HandleKeyboardSpecialEvent(int key, int x, int y);
    static void HandleMouseClickEvent(int button, int state, int x, int y);
    static void HandleMousePressedMovementEvent(int x, int y, int dx, int dy);

    static NxActor *CreateBox(const NxVec3 &pos, const NxVec3 &dim, const NxVec3 &orientation = NxVec3(0.0f, 0.0f, 0.0f), bool isStatic = false, float density = 1.0f);
    static NxActor *CreateSphere(const NxVec3 &pos, float radius, bool isStatic = false, float density = 1.0f);

    static NxMat33 CalcOrientationMatrix(const NxVec3 &angles);

private:
    static void Draw();

    static void ThrowBall(float size, float power);
};

#endif //PHYSX_LOGIC_H
